//
//  MissingManageViewController.m
//  Manage
//
//  Created by 杨康 on 2017/11/12.
//  Copyright © 2017年 杨康. All rights reserved.
//

#import "MissingManageViewController.h"
#import "MissingDetailsViewController.h"
@interface MissingManageViewController ()
@property(nonatomic,assign)NSInteger acType;
@property(nonatomic,strong)ykTableView *tableView;
@end

@implementation MissingManageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"报失管理";
    
    UIButton *leftButton=(UIButton *)self.navigationItem.leftBarButtonItem.customView;
    leftButton.selected=YES;
    
    
    self.tableView =[SingLeton myTableViewWithFrame:CGRectMake(0, TOP_HEIGHT+50, SCREEN_WIDTH, SCREEN_HEIGHT-TOP_HEIGHT-50)  withRefresh:NO didSelect:^(ykTableView *tableView, NSIndexPath *indexPath) {
        
        MissingDetailsViewController *vc=[[MissingDetailsViewController alloc]init];
        switch (self.acType) {
            case 0:
                vc.type=@"待审核";
                break;
            case 1:
                vc.type=@"报失中";
                break;
            case 2:
                vc.type=@"已找到";
                break;
            case 3:
                vc.type=@"已取消";
                break;
                
            default:
                break;
        }
        
        [self.navigationController pushViewController:vc animated:YES];
        
    }];
    
    [self.view addSubview:self.tableView];
    
    
    
    
    
    UISegmentedControl *TypeSegmentedControl = [[UISegmentedControl alloc] initWithItems:
                                                [NSArray arrayWithObjects:
                                                 @"待审核",
                                                 @"报失中",
                                                 @"已找到",
                                                 @"已取消",
                                                 nil]];
    TypeSegmentedControl.apportionsSegmentWidthsByContent = YES;
    TypeSegmentedControl.layer.masksToBounds=YES;
    TypeSegmentedControl.layer.cornerRadius=5;
    TypeSegmentedControl.tintColor = [UIColor colorF];
    NSDictionary *dics = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor color6],NSForegroundColorAttributeName,[UIFont systemFontOfSize:12.0],NSFontAttributeName,nil];
    [TypeSegmentedControl setTitleTextAttributes:dics forState:UIControlStateNormal];
    [TypeSegmentedControl setBackgroundImage:[NetworkPath createImageWithColor:[UIColor colorQ]]
                                    forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
    [TypeSegmentedControl setBackgroundImage:[NetworkPath createImageWithColor:[UIColor whiteColor]]
                                    forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    
    [TypeSegmentedControl addTarget:self action:@selector(TypeAction:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:TypeSegmentedControl];
    [TypeSegmentedControl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(TOP_HEIGHT+10);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-20, 30));
        
    }];
    
    
    TypeSegmentedControl.selectedSegmentIndex=0;
    [self TypeAction:TypeSegmentedControl];
}
- (void)TypeAction:(UISegmentedControl *)segmentedControl
{
    self.acType = segmentedControl.selectedSegmentIndex;
    switch (self.acType) {
        case 0:
        {
            self.tableView.className=@"MissCell";
            NSMutableArray *itemArr=[NSMutableArray array];
            
            
            for (int i=0; i<5; i++) {
                MissData *dataObj=[[MissData alloc]init];
                dataObj.image=@"";
                dataObj.name=@"电动车名称";
                dataObj.color=@"蓝色";
                dataObj.storeName=@"心艺电动车店";
                dataObj.time=@"06-24";
                dataObj.address=@"我家在东北松花江上啊我家在东北松花江上啊";
                dataObj.coin=@"88";
                dataObj.state=@"1";
                [itemArr addObject:dataObj];
                
                
                
            }
            [self.tableView.dataArray addObject:itemArr];
            [self.tableView reloadData];
        }
            break;
        case 1:
        {
            self.tableView.className=@"MissCell";
            NSMutableArray *itemArr=[NSMutableArray array];
            
            
            for (int i=0; i<5; i++) {
                MissData *dataObj=[[MissData alloc]init];
                dataObj.image=@"";
                dataObj.name=@"电动车名称";
                dataObj.color=@"蓝色";
                dataObj.storeName=@"心艺电动车店";
                dataObj.time=@"06-24";
                dataObj.address=@"我家在东北松花江上啊我家在东北松花江上啊";
                dataObj.coin=@"88";
                dataObj.state=@"2";
                [itemArr addObject:dataObj];
                
                
                
            }
            [self.tableView.dataArray addObject:itemArr];
            [self.tableView reloadData];
            
        }
            break;
        case 2:
        {
            self.tableView.className=@"MissCell";
            NSMutableArray *itemArr=[NSMutableArray array];
            
            
            for (int i=0; i<5; i++) {
                MissData *dataObj=[[MissData alloc]init];
                dataObj.image=@"";
                dataObj.name=@"电动车名称";
                dataObj.color=@"蓝色";
                dataObj.storeName=@"心艺电动车店";
                dataObj.time=@"06-24";
                dataObj.address=@"我家在东北松花江上啊我家在东北松花江上啊";
                dataObj.coin=@"88";
                dataObj.state=@"3";
                [itemArr addObject:dataObj];
                
                
                
            }
            [self.tableView.dataArray addObject:itemArr];
            [self.tableView reloadData];
        }
            break;
        case 3:
        {
            self.tableView.className=@"MissCell";
            NSMutableArray *itemArr=[NSMutableArray array];
            
            
            for (int i=0; i<5; i++) {
                MissData *dataObj=[[MissData alloc]init];
                dataObj.image=@"";
                dataObj.name=@"电动车名称";
                dataObj.color=@"蓝色";
                dataObj.storeName=@"心艺电动车店";
                dataObj.time=@"06-24";
                dataObj.address=@"我家在东北松花江上啊我家在东北松花江上啊";
                dataObj.coin=@"88";
                dataObj.state=@"4";
                [itemArr addObject:dataObj];
                
                
                
            }
            [self.tableView.dataArray addObject:itemArr];
            [self.tableView reloadData];
        }
            break;
            
            
        default:
            break;
    }
}


@end
